
<div class="box" oncontextmenu=self.event.returnValue=false onselectstart="return false">
  <div class="box-header">
      
    <div class="row">
        <div class="col-sm-6">
            <div class="btn-group">

                <a class="btn" href="/admin.php/article/articlelist">默认</a>
                <!-- id排序 -->
                {if  condition='isset($_GET["sort"]) and isset($_GET["order"])'}
                        {if  condition='$_GET["sort"] eq "desc" and $_GET["order"] eq "id"'}
                        <a class="btn" href="/admin.php/article/articlelist?order=id&sort=asc">id ↓</a>
                        {/if}
                        {if  condition='$_GET["sort"] eq "asc" and $_GET["order"] eq "id"'}
                        <a class="btn" href="/admin.php/article/articlelist?order=id&sort=desc">id ↑</a>
                        {/if}
                    {else/}
                        <a class="btn" href="/admin.php/article/articlelist?order=id&sort=desc">id ↓</a>
                {/if}
                <!-- 更新时间排序 -->
                {if  condition='isset($_GET["sort"]) and isset($_GET["order"])'}
                    {if  condition='$_GET["sort"] eq "desc" and $_GET["order"] eq "update_date"'}
                        <a class="btn" href="/admin.php/article/articlelist?order=update_date&sort=asc">更新日期 ↓</a>
                    {/if}
                    {if  condition='$_GET["sort"] eq "asc" and $_GET["order"] eq "update_date"'}
                        <a class="btn" href="/admin.php/article/articlelist?order=update_date&sort=desc">更新日期 ↑</a>
                    {/if}
                    {else/}
                         <a class="btn" href="/admin.php/article/articlelist?order=update_date&sort=desc">更新日期</a>
                {/if}
            </div>
            <ob_link {if condition="!isPower('article/articleadd')"} hidden{/if}>
            <a  class="btn" onclick="edit_data('{:url("articleAdd")}')"><i class="fa fa-edit" ></i> 新 增</a>
            </ob_link>

            <ob_link><a class="btn" href="{:url('uploadFile')}"><i class="fa fa-plus"></i> 导 入</a></ob_link>

            <ob_link  {if condition="!isPower('article/exportData')"} hidden{/if}>
            <a  class="btn" onclick="exportData('{:url("exportData")}')"><i class="fa fa-download" ></i> 导 出</a>
            </ob_link>
        </div>
        
        <div class="col-sm-6">
            <div class="box-tools search-form pull-right">
                <div class="input-group input-group-sm">
                    <div id="filed-box" style=" position: absolute;width: 200px;right: 240px;    border-radius: 3px;display: inline-block">
                        <select style="padding: 0 12px;height: 30px;" name="field" id="select-box" class="form-control select-box select_filed">
                            <option value="">请选择要搜索的列</option>
                            {volist name="fields_list" id="vo"}
                            <option value="{$vo.field}" {if condition = "isset($_GET['field'])"}{if condition = "$_GET['field'] eq $vo['field']"}selected{/if}{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                    {if condition = "isset($_GET['field'])"}

                    {if condition = "$_GET['field'] neq 'category_id'"}

                    <input type="text" name="search_data" id="key_search" style="width: 200px;" class="form-control pull-right" value="{:input('search_data')}" placeholder="请输入关键词~">
                    {else/}

                   <select style="height: 30px;width: 200px;" name="search_data" id="select_value_box" class="form-control field_select_zhj select-box select_filed  pull-right">
                    <option value="">请选择要搜索的列</option>
                     {volist name="article_category_list" id="vo"}
                     <option value="{$vo.id}" {if condition = "isset($_GET['search_data'])"}{if condition = "$_GET['search_data'] eq $vo['id']"}selected{/if}{/if}>{$vo.name}</option>
                    {/volist}
                    </select>
                    {/if}
                    {else/}
                    <input type="text" name="search_data" id="key_search" style="width: 200px;" class="form-control pull-right" value="{:input('search_data')}" placeholder="请输入关键词~">
                    {/if}
                    <div class="input-group-btn">
                      <button type="button" id="search"  url="{:url('articlelist')}" class="btn btn-info btn-flat"><i class="fa fa-search"></i></button>
                    </div>

                </div>
           </div>
        </div>
    </div>

  </div>
  <div class="box-body table-responsive">
    <table  class="table table-bordered table-hover">
      <thead>
      <tr>
          <th class="checkbox-select-all">
              <label>
                <input class="flat-grey js-checkbox-all" type="checkbox">
              </label>
          </th>
          {volist name="fields_list" id="vo"}
             <th width="{$vo.width}%"><input  class="col-name" field="{$vo.id}"  style="background-color:#fff;width: 100%;border: 0px" type="text" value="{$vo.name}" {if condition="$is_power eq 0"}style="cursor:not-allowed ;" disabled{/if} ></th>
          {/volist}
            <th width="15%">更新日期</th>
            <th>操作</th>
      </tr>
      </thead>
      
      {notempty name='list'}
        <tbody>
            {volist name='list' id='vo'}
                <tr>
                  <td>
                    <label>
                        <input class="flat-grey" type="checkbox" name="ids" value="{$vo.id}">
                    </label>
                  </td>
                  <td onclick="isPower(this)" data="{$vo.name}" field="name" data-id="{$vo.id}">{$vo.name}</td>
                  <td onclick="isPower(this)" data="{$vo.phone}" field="phone" data-id="{$vo.id}">{$vo.phone}</td>
                  <td onclick="isPower(this)" data="{$vo.category_name}" field="category_id" data-id="{$vo.id}" category="{$vo.category_id}">{$vo.category_name}</td>
                  <td onclick="isPower(this)" data="{$vo.describe}" field="describe" data-id="{$vo.id}">{$vo.describe}</td>
                  <td onclick="isPower(this)" data="{$vo.operator}" field="operator" data-id="{$vo.id}">{$vo.operator}</td>
                  <td onclick="isPower(this)" data="{$vo.province}" field="province" data-id="{$vo.id}">{$vo.province}</td>
                  <td onclick="isPower(this)" data="{$vo.city}" field="city" data-id="{$vo.id}">{$vo.city}</td>
                  <td onclick="isPower(this)" data="{$vo.county}" field="county" data-id="{$vo.id}">{$vo.county}</td>
                  <td onclick="isPower(this)" data="{$vo.hometown}" field="hometown" data-id="{$vo.id}">{$vo.hometown}</td>
                  <td onclick="isPower(this)" data="{$vo.street}" field="street" data-id="{$vo.id}">{$vo.street}</td>
                  <td onclick="isPower(this)" data="{$vo.product}" field="product" data-id="{$vo.id}">{$vo.product}</td>
                  <td onclick="isPower(this)" data="{$vo.identification}" field="identification" data-id="{$vo.id}">{$vo.identification}</td>
                  <td onclick="isPower(this)" data="{$vo.update_date}" field="update_date" data-id="{$vo.id}">{$vo.update_date}</td>
                  <td class="col-md-2 text-center">
                      <ob_link  {if condition="!isPower('article/articleedit')"} hidden{/if}><button class="btn" onclick="edit_data('{:url('articleEdit', array('id' => $vo['id']))}')"><i class="fa fa-edit"></i> 编辑</button></ob_link>
                      <ob_link><a class="btn confirm ajax-get" href="{:url('setStatus', array('ids' => $vo['id'], 'status' => $Think.DATA_DELETE))}"><i class="fa fa-trash-o"></i> 删 除</a></ob_link>
                  </td>
                </tr>
            {/volist}
        </tbody>
        {else/}
        <tbody><tr class="odd"><td colspan="8" class="text-center" valign="top">{:config('empty_list_describe')}</td></tr></tbody>
      {/notempty}
    </table>

      <div class="lockscreen-footer">
          <ob_link><a class="btn batch_btn confirm ajax-post" value="{$Think.DATA_DELETE}"  href="{:url('setStatus')}"><i class="fa fa-trash"></i> 删 除</a></ob_link>
      </div>
  </div>
  <div class="box-footer clearfix text-center">
      {$list->render()}
  </div>
</div>


<!-- 修改数据弹窗 -->
<div class="panel panel-primary update-data-div" id="update-panel" hidden>
<div class="panel-heading">
<h3 class="panel-title">修改数据</h3>
</div>
<div class="panel-body">
<input oncontextmenu="return false" oncopy="return false" oncut="return false"  type="text" id="update_value" class="form-control">
<ul class="nav nav-pills">
<li role="presentation" class="active concle_button"><a href="javascript:void(0)" onclick="closeUpdate()">取消</a></li>
<li role="presentation" class="active"><a href="javascript:void(0)" onclick="saveUpdate()">保存</a></li>
</ul>
</div>
</div>

<!-- 修改分类弹窗 -->
<div class="panel panel-primary update-data-div" id="update-panel-category" hidden>
    <div class="panel-heading">
        <h3 class="panel-title">修改数据</h3>
    </div>
    <div class="panel-body">
        <select name="category_id"  id="category_id" class="form-control" oncontextmenu="return false" oncopy="return false" oncut="return false" >
            {volist name='article_category_list' id='vo1'}
              <option value="{$vo1['id']}">{$vo1['name']}</option>
            {/volist}
        </select>
        <ul class="nav nav-pills">
            <li role="presentation" class="active concle_button"><a href="javascript:void(0)" onclick="closeUpdate()">取消</a></li>
            <li role="presentation" class="active"><a href="javascript:void(0)" onclick="saveUpdate()">保存</a></li>
        </ul>
    </div>
</div>

<!-- 修改省弹窗 -->
<div class="panel panel-primary update-data-div" id="update-panel-province" hidden >
    <div class="panel-heading">
        <h3 class="panel-title">修改数据</h3>
    </div>
    <div class="panel-body">
        <input name="province"  id="province_" class="form-control" oncontextmenu="return false" oncopy="return false" oncut="return false" >
        <ul class="nav nav-pills">
            <li role="presentation" class="active concle_button"><a href="javascript:void(0)" onclick="closeUpdate()">取消</a></li>
            <li role="presentation" class="active"><a href="javascript:void(0)" onclick="saveUpdate()">保存</a></li>
        </ul>
    </div>
</div>


<!-- 修改市弹窗 -->
<div class="panel panel-primary update-data-div" id="update-panel-city" hidden>
    <div class="panel-heading">
        <h3 class="panel-title">修改数据</h3>
    </div>
    <div class="panel-body">
        <input name="city"  id="city_" class="form-control" oncontextmenu="return false" oncopy="return false" oncut="return false" >
        <ul class="nav nav-pills">
            <li role="presentation" class="active concle_button"><a href="javascript:void(0)" onclick="closeUpdate()">取消</a></li>
            <li role="presentation" class="active"><a href="javascript:void(0)" onclick="saveUpdate()">保存</a></li>
        </ul>
    </div>
</div>

<!-- 修改区县弹窗 -->
<div class="panel panel-primary update-data-div" id="update-panel-county" hidden>
    <div class="panel-heading">
        <h3 class="panel-title">修改数据</h3>
    </div>
    <div class="panel-body">
        <input name="county"  id="county_" class="form-control" oncontextmenu="return false" oncopy="return false" oncut="return false" >
        <ul class="nav nav-pills">
            <li role="presentation" class="active concle_button"><a href="javascript:void(0)" onclick="closeUpdate()">取消</a></li>
            <li role="presentation" class="active"><a href="javascript:void(0)" onclick="saveUpdate()">保存</a></li>
        </ul>
    </div>
</div>

</div>
<script>
    //如果是分类则改变输入框
    $(function(){
        $(".select_filed").change(function () {
            if($(".select_filed").val()=='category_id'){  //如果选择的是数据分类则移除input
                $("#key_search").remove();
                if($("#select_value_box").length > 0){  //如果选择框存在，则不处理
                    //$("#select_value_box").remove();
                  }else{  //没有选择框则添加选择框
                    $("#filed-box").after(
                        '<select style="height: 30px;width: 200px;" name="search_data" id="select_value_box" class="form-control select-box select_filed  pull-right">'+
                        '<option value="">请选择要搜索的列</option>'+
                        ' {volist name="article_category_list" id="vo"}'+
                        '  <option value="{$vo.id}" {if condition = "isset($_GET['search_data'])"}{if condition = "$_GET['search_data'] eq $vo['id']"}selected{/if}{/if}>{$vo.name}</option>'+
                    '{/volist}'+
                    '</select>'
                );
                }
            }else{  //如果不是数据分类，则添加input框
                if($("#key_search").length > 0){

                }else{
                    $("#select_value_box").remove();
                    $("#filed-box").after(
                        '<input type="text" name="search_data" id="key_search" style="width: 200px;" class="form-control pull-right"' +
                        ' placeholder="请输入关键词~" value="" >'
                    );
                }
            }
        })
    })
    function exportData(url){
        var query  = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
        window.location.href = url;
    }
</script>